package com.fengba.nanzhi.utils;

import android.app.Activity;
import android.util.Log;
import android.widget.ProgressBar;
import android.widget.Toast;

/**
 * 作者： 叶应是叶
 * 时间： 2017/4/2 15:41
 * 描述：
 */
public class ToastUtil {

    public static void showToast(final Activity activity, final String message, final ProgressBar JuHua) {
        if ("main".equals(Thread.currentThread().getName())) {
            //Log.e("ToastUtil", "在主线程");
            Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
            if (JuHua!=null)
            {
                JuHua.setVisibility(ProgressBar.INVISIBLE);
            }
        } else {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    //Log.e("ToastUtil", "不在主线程");
                    Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
                    if (JuHua!=null)
                    {
                        JuHua.setVisibility(ProgressBar.INVISIBLE);
                    }
                }

            });
        }
    }

}
